package com.demo;

import jakarta.annotation.PostConstruct;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageProducer_order {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendMessage(String topic, String message) {
        rocketMQTemplate.syncSendOrderly(topic, message, "order-key");
    }
//    @PostConstruct
     public void init() {
        for (int i = 0; i < 100; i++) {
            sendMessage("my-topic-order", "Hello, RocketMQ-order!" + i);
        }
    }
}